# -*- coding: utf-8 -*-

import logging
import os
import sys
import time

sys.path.append(os.path.abspath(os.path.dirname(os.path.dirname(
    os.path.dirname(os.path.dirname(os.path.dirname(__file__)))))))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "base.settings")

from common.lottery import LOTTERY_TYPE, DIY_LOTTERY
from common.lottery.cyclical.handler import generate_and_fill_diy


def main(date):
    if date:
        return
    lottery_type = LOTTERY_TYPE.FF_SSC
    while True:
        try:
            generate_and_fill_diy(lottery_type)
        except Exception as e:
            logging.exception(u'%s error: %s' % (DIY_LOTTERY.get(lottery_type), e))
        time.sleep(10)


if __name__ == '__main__':
    main(None)
